﻿<UserControl
    x:Class="Microsoft.Media.ISOProfiler.BoxViewer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Microsoft.Media.ISOProfiler"
    xmlns:converters="using:Microsoft.Media.ISOProfiler.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">


    <UserControl.Resources>

        <!-- Converters -->
        <converters:BoxPropertiesToTextConverter x:Key="BoxPropertiesToTextConverter" />
        <converters:BoxToTextConverter x:Key="BoxToTextConverter" />

    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <ListBox x:Name="BoxTreeView" VirtualizingStackPanel.VirtualizationMode="Standard" ItemsSource="{Binding Nodes}" MinWidth="300">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <!-- indentation column -->
                            <ColumnDefinition Width="20" />
                            <!-- treeview expand/collapse column -->
                            <ColumnDefinition />
                            <!-- Name column -->
                        </Grid.ColumnDefinitions>

                        <Rectangle Width="{Binding IndentationDistance}" />
                        <ToggleButton Grid.Column="1" IsChecked="{Binding IsExpanded, Mode=TwoWay}" Visibility="{Binding ExpanderVisibility}" Grid.RowSpan="2" VerticalAlignment="Center">
                            <ToggleButton.Template>
                                <ControlTemplate>
                                    <Border Width="16" Height="16" Background="Transparent">
                                        <Path x:Name="ExpandPath" Fill="#DDD" Stroke="#CCC" Data="M0,0L0,6L6,0Z" VerticalAlignment="Center">
                                            <Path.RenderTransform>
                                                <RotateTransform Angle="{Binding ArrowAngle}" CenterX="3" CenterY="3"/>
                                            </Path.RenderTransform>
                                        </Path>
                                    </Border>
                                </ControlTemplate>
                            </ToggleButton.Template>
                        </ToggleButton>

                        <StackPanel Grid.Column="2" Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Model, Converter={StaticResource BoxToTextConverter}}" />
                        </StackPanel>

                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <!--<sdk:GridSplitter Grid.Column="1" HorizontalAlignment="Left" Width="10" Margin="0,0,0,0" />-->
        <TextBox x:Name="BoxPropertyGrid" AcceptsReturn="True" TextWrapping="Wrap" IsReadOnly="True" Text="{Binding ElementName=BoxTreeView, Path=SelectedItem.Model, Converter={StaticResource BoxPropertiesToTextConverter}}" Grid.Column="1" FontSize="{StaticResource ControlContentThemeFontSize}" Margin="10"/>
        <!--<local:PropertyGrid x:Name="BoxPropertyGrid" SelectedObject="{Binding ElementName=BoxTreeView, Path=SelectedItem.Model}" Grid.Column="1" FontSize="{StaticResource ControlContentThemeFontSize}" Margin="10"/>-->
    </Grid>
</UserControl>
